<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <form>
        <p>手机号：<input id="mobile" name="mobile"/>
            <input type="button" id="getValidCode" value="发送验证码"/></p>
        <p>验证码：<input id="validCode" name="validCode"/><span id="validCode_prompt"></span></p>
        <input type="button" id="loginBtn" value="登录"/>
    </form>
<script src="/js/jquery-1.12.4.js"></script>
<script>
    $("#getValidCode").click(function(){
        if(!$("#mobile").val()){
            alert("请输入手机号码！");
            return;
        }
        alert("a");
        $.ajax({
            url:"/getValidCode.do",
            method:"post",
            data: {mobile:$("#mobile").val()},
            dataType:"json",
            success:function(result){
                alert(result.msg);
            },
            error:function () {
                alert("失败");
            }
        });
    });
    $("#validCode").blur(function(){
        if(!$("#mobile").val()){
            alert("请输入手机号码！");
            return;
        }
        if(!$("#validCode").val()){
            alert("请输入验证码！");
            return;
        }
        $.ajax({
            url:"/checkValidCode.do",
            method:"post",
            data: {mobile:$("#mobile").val(),validCode:$("#validCode").val()},
            dataType:"json",
            success:function(result){
                alert(result.msg);
            }
        });
    })

</script>
</body>
</html>